How can I resolve the conversion error for smalldatetime in my SQL query